Skip to content

Conversation

@jhohm
Copy link
Contributor

@jhohm jhohm commented May 20, 2025

Resolves #118234 by checking for the SystemRoot environment variable and, if it is missing, setting it based on GetWindowsDirectoryW.

As described in the issue, the default path of the provider DLL is stored in the registry as "%SystemRoot%\System32\mswsock.dll" which does not resolve without SystemRoot set (typically to "C:\Windows").

jhohm added 3 commits May 20, 2025 12:25
Resolves python#118234 by checking for the SystemRoot environment variable
and, if it is missing, setting it based on GetWindowsDirectoryW.

As described in the issue, the default path of the provider DLL is
stored in the registry as "%SystemRoot%\System32\mswsock.dll" which does
not resolve without SystemRoot set (typically to "C:\Windows").
@vstinner
Copy link
Member

I don't think that it's a good idea to set SYSTEMROOT environment variable on import socket. It's a surprising side effect. I suspect that other Python stdlib modules don't work well without SYSTEMROOT.

cc @zooba

@zooba
Copy link
Member

zooba commented May 20, 2025

Yeah, I don't love this, and certainly not as part of socketmodule. It might make sense in python.c, to detect whenever someone launches Python with an empty environment, but it's probably even better in subprocess to warn people before they launch with an empty environment.

In my experience, this only ever happens when launching from Python. I've not seen any other language cause it. This list linked in the bug has the main ones, and we should probably just ensure that subprocess always sets them if the caller omits them.

@jhohm
Copy link
Contributor Author

jhohm commented May 21, 2025

Sent gh-134435 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sockets and asyncio on Windows depend on SYSTEMROOT env var

3 participants